#ifndef UBLK_H
#define UBLK_H

#include <liburing.h>
#include <stdbool.h>
#include <linux/ublk_cmd.h>

#include "cache_manager.h"
#include "fetcher.h"
#include "thread_pool.h"

typedef struct {
    int dev_id;
    int ublk_fd;
    struct io_uring ring;
    cache_manager_t* cm;
    fetcher_t* fetcher;
    thread_pool_t* worker_pool;
} ublk_daemon_t;

typedef struct {
    ublk_daemon_t *daemon;
    int tag;
    __u64 lba;
    int len;
    void *user_ptr;
} io_request_t;

int ublk_daemon_run(int dev_id, const char* lba_map_path, const char* cache_dir, const char* registry, const char* repo);

#endif